﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Basic4Net.BusinessRules;
using Basic4Net.Entities;
using Basic4Net.OAWeb.Base;

namespace Basic4Net.OAWeb.Module_Base
{
    public partial class WorkTitleAndRate : BasePage
    {
        /// <summary>
        /// Position逻辑层
        /// </summary>
        private static Position _postionInstance;
        protected static Position HPositon
        {
            get { return _postionInstance ?? (_postionInstance = new Position()); }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            Bind();
        }

        protected void btnBind_Click(object sender, EventArgs e)
        {
            Bind();
        }

        /// <summary>
        /// 绑定职称
        /// </summary>
        private void Bind()
        {
            IList<t_Position> list = HPositon.GetAllPosition();
            Repeater1.DataSource = list;
            Repeater1.DataBind();
        }

        /// <summary>
        /// 更新职称
        /// </summary>
        /// <param name="groupId">职称id</param>
        /// <param name="groupName">职称名</param>
        /// <param name="groupRate">系数</param>
        /// <returns></returns>
        [System.Web.Services.WebMethod]
        public static string UpdateGroup(int groupId, string groupName, double groupRate)
        {
            string strmsg = String.Empty;
            var p = new t_Position {RID = groupId, FName = groupName, Factor = groupRate, SchoolMark = SchoolMark};
            if(groupId == 0)
                HPositon.Add(p, ref strmsg);
            else
                HPositon.Update(p, ref strmsg);
            return strmsg;
        }

        /// <summary>
        /// 删除职称
        /// </summary>
        /// <param name="groupId">职称id</param>
        /// <returns></returns>
        [System.Web.Services.WebMethod]
        public static string DelGroup(int groupId)
        {
            string strmsg = String.Empty;
            var p = new t_Position {RID = groupId, SchoolMark = SchoolMark};
            HPositon.Delete(p, ref strmsg);
            return strmsg;
        }
    }
}